# 中文GB2312/GBK编码示例
text = "中国"
gbk_encoded = text.encode('gbk')
print(gbk_encoded)  # b'\xd6\xd0\xb9\xfa'


# Unicode 字符集包含全球所有字符
characters = [
    'A',        # 拉丁字母
    '中',       # 中文
    '🍕',       # Emoji
    'α',        # 希腊字母
    'あ'        # 日文
]

for char in characters:
    print(f"字符: {char}, Unicode码点: U+{ord(char):04X}")


#utf-8

text = "Hello 世界 🍕"
utf8_encoded = text.encode('utf-8')
print(f"UTF-8编码: {utf8_encoded}")
print(f"长度: {len(utf8_encoded)} 字节")

# 分析每个字符的UTF-8编码
for char in text:
    encoded_char = char.encode('utf-8')
    print(f"'{char}' -> {encoded_char} ({list(encoded_char)})")